home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef __CPOINT__
- #define __CPOINT__
-
- #include <Quickdraw.h>
-
- class CRect;
-
- typedef SInt16 GraphicalUnit;
-
- class CPoint
- {
- public:
- Point fPoint;
-
- // constructors
- inline CPoint();
- inline CPoint(GraphicalUnit X, GraphicalUnit Y);
- inline CPoint(const CPoint& pt);
- inline CPoint(const Point& pt);
-
- // destructor
- inline ~CPoint() {};
-
- // assignment
- CPoint& operator=(const CPoint &from);
- void Set(GraphicalUnit X, GraphicalUnit Y);
-
- void ConstrainTo(const CRect& rect);
-
- // arithmetic
- CPoint operator+(const CPoint&) const;
- CPoint operator-(const CPoint&) const;
- CPoint& operator+=(const CPoint&);
- CPoint& operator-=(const CPoint&);
-
- // relational
- Boolean operator!=(const CPoint&) const;
- Boolean operator==(const CPoint&) const;
-
- // conversion
- inline operator Point*();
- inline operator const Point*() const;
- inline operator Point() const;
- inline GraphicalUnit X(void) const;
- inline GraphicalUnit Y(void) const;
- };
-
- inline CPoint::CPoint()
- {
- }
-
- inline CPoint::operator Point*()
- {
- return &fPoint;
- }
-
- inline CPoint::operator const Point*() const
- {
- return (Point * const)&fPoint;
- }
-
- inline CPoint::operator Point() const
- {
- return fPoint;
- }
-
- inline CPoint::CPoint(GraphicalUnit X, GraphicalUnit Y)
- {
- fPoint.h = X;
- fPoint.v = Y;
- }
-
- inline CPoint::CPoint(const CPoint& pt)
- {
- fPoint.h = pt.fPoint.h;
- fPoint.v = pt.fPoint.v;
- }
-
- inline CPoint::CPoint(const Point& pt)
- {
- fPoint.h = pt.h;
- fPoint.v = pt.v;
- }
-
- inline CPoint &CPoint::operator=(const CPoint& from)
- {
- // don't need to worry about "this==from"
- fPoint.h = from.fPoint.h;
- fPoint.v = from.fPoint.v;
- return *this;
- }
-
- inline void CPoint::Set(GraphicalUnit X, GraphicalUnit Y)
- {
- fPoint.h = X;
- fPoint.v = Y;
- }
-
- inline GraphicalUnit CPoint::X(void) const
- {
- return fPoint.h;
- }
-
- inline GraphicalUnit CPoint::Y(void) const
- {
- return fPoint.v;
- }
-
-
- #endif
-